<script lang="ts">
export default {
  name: 'Test-test1-3'
}
</script>

<template>
  <h2>待办事项列表 - 测试使用 reactive 数组来处理列表项的添加与移除操作。</h2>
  <div class="test">
    <div class="todo-list">
      <h2>Todo List</h2>
      <input placeholder="Add a new todo" v-model="content" />
      <button @click="addTodo">Add</button>

      <ul v-for="(sampleList, index) in sampleLists" :key="index">
        <li>
          {{ sampleList }}
          <button @click="removeTodo(index)">remove</button>
        </li>
      </ul>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue'

const sampleLists = reactive(['1. 清除杂物', '2. 好好学习', '3. 多读史书'])
const content = ref('')
function addTodo() {
  sampleLists.push(content.value)
}
function removeTodo(index: number) {
  sampleLists.splice(index, 1)
}
</script>

<style scoped>
.todo-list {
  text-align: center;
}

input {
  padding: 5px;
  margin-right: 10px;
}

button {
  padding: 5px;
  background-color: #2196f3;
  color: white;
  border: none;
  cursor: pointer;
}

button:hover {
  background-color: #0b7dda;
}

ul {
  list-style: none;
  padding: 0;
}

li {
  cursor: pointer;
  padding: 10px;
  margin: 5px 0;
  background-color: #f1f1f1;
}

li:hover {
  background-color: #ddd;
}

body {
  padding: 20px;
}
h2 {
  color: red;
}
h3 {
  color: rgb(220, 85, 85);
}
h4 {
  color: skyblue;
}
.hr-style {
  border: 3px solid gold;
  margin: 20px 0;
}
.group {
  border: 4px solid rgb(102, 215, 85);
  margin: 10px;
  padding: 10px;
}
.group3 {
  border: 2px solid rgb(64, 163, 199);
  margin: 10px;
  padding: 10px;
}
.note {
  margin: 10px;
  padding: 10px;
  border: 3px solid rgb(221, 121, 202);
}
.note p {
  color: rgb(226, 106, 204);
  font-weight: bold;
}
</style>
